/**
 * Created by Baggio on 2018-10-16.
 */
$(function () {
    $("#gamePetWikiAdd").click(function () {
        $("#form-media-add").ajaxSubmit({
            type: "POST",
            url: '/gamePetWiki/modifyGamePetWiki.html',
            data: $('#form-media-add').serialize(),// 你的formid
            dataType:"json",
            error: function (request) {
                alert("Connection error");
            },
            beforeSend: function () {
                console.log("begin...............");
                $(".loading").show();
            },
            success: function (data) {

                console.log(data);
                if (data.code != 0) {
                    layer.msg('操作成功!', {icon: 6, time: 1000}, function () {
                        console.log(data);
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    })
                }

            },
            complete: function (XMLHttpRequest, textStatus) {
                // alert('远程调用成功，状态文本值：'+textStatus);
                console.log("end...............");
                $(".loading").hide();
            },
        });

    })
});

function playMedia(url) {
    var bgm = document.getElementById('bgMusic');
    $("#bgMusic").attr("src",url);
    bgm.play();
}
function modifiyStaus(tid, status) {
    var postData = {tid: tid, status: status == 1 ? 0 : 1};
    console.log(postData);
    $.ajax({
        type: 'POST',
        data: postData,
        url: '/gamePetWiki/modifyGamePetWikiStatus.html',
        dataType: 'json',
        success: function (data) {
            if (data.code != 1) {
                alert(data.msg);
                return;
            }
            alert("设置成功！");
            window.location.reload();
        }
    })

}